//
//  ViewController.m
//  QRCodeCreater
//
//  Created by 蔡成汉 on 15/5/27.
//  Copyright (c) 2015年 JW. All rights reserved.
//

#import "ViewController.h"
#import "QRCodeGenerator.h"

@interface ViewController ()
{
    UIImageView *myImageView;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(100, 100, 100, 30);
    [button setTitle:@"生成二维码" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [button setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
    [button addTarget:self action:@selector(buttonIsTouch:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    myImageView = [[UIImageView alloc]initWithFrame:CGRectMake((self.view.frame.size.width/2-150), 150, 300, 300)];
    myImageView.backgroundColor = [UIColor clearColor];
    myImageView.layer.borderWidth = 1;
    myImageView.layer.borderColor = [[UIColor blueColor]CGColor];
    [self.view addSubview:myImageView];
}

-(void)buttonIsTouch:(UIButton *)paramSender
{
    myImageView.image = [QRCodeGenerator qrImageForString:@"我们私奔吧我们私奔吧我们私奔吧" imageSize:myImageView.bounds.size.width];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
